<?php
/**
* （6W0500）转帐交易结果查询
*/
class Conf6w0500 extends Abccbconf
{
    public function getTransaction()
    {
        $this->_ccbConf->getTransactionHeader();
    }

    public function getTransactionBody()
    {
        /**
         *  原请求序列号 varChar(16) F 原转账交易请求序列号 
         */
        $body['REQUEST_SN1'] = $this->parameter['REQUEST_SN1'];

        /**
         *  原转账凭证号 varChar(12) T 原转账交易应答报文返回的凭证号 
         */
        $body['CREDIT_NO1'] = isset($this->parameter['CREDIT_NO1']) ? $this->parameter['CREDIT_NO1'] : '';

        return $body;
    }

    public function validateParameter()
    {
        if ( empty($this->parameter['REQUEST_SN1']) ) {
            throw new Exception("请输入原请求序列号", 1);
        }
    }

    /**
     * 解析返回回来的数据
     */
    public function parsesResult($response)
    {
        $dealResult = (int)$response->TX_INFO->DEAL_RESULT;

        $transaction['message'] = $this->getReturnCodeMsg($dealResult). "|". (string)$response->RETURN_MSG. "|". (string)$response->TX_INFO->MESSAGE;
        $transaction['response_content'] = json_encode($response);
        if ( (string)$response->RETURN_CODE === '000000' && $dealResult == 4 ) { // 验证是否转账成功
            $transaction['status'] = 1; //交易成功
        }
        return $transaction;
    }
}